<template>
  <div class="wrap">
    <div class="search">
      <input type="text" v-model="username" @keyup.enter="search" placeholder="名称搜索">
      <img src="../assets/search.png" @click="search" alt="">
    </div>
      <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
        <div class="item" v-for="(item,idx) in list" :key="idx" @click="next(item)">
          <div class="infos">
            <img :src="item.avatar" :onerror="defaultImg" alt="">
            <div>
              <p>{{item.username}}</p>
              <span>订单数:{{item.total}}</span>
            </div>
          </div>
          <img class="icon" src="../assets/right.png" alt="">
        </div>
         <van-empty description="暂无数据" v-if="state==1"/>
      </van-pull-refresh>
  </div>
</template>
<style lang="scss" scoped>
.null {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 80vh;
  p {
    color: #999;
    font-size: 0.48rem;
  }
}
.search {
  background: #eeeded;
  height: 1.066667rem;
  width: 9.2rem;
  margin: 0.306667rem auto 0.4rem;
  border-radius: 0.266667rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  input {
    border: none;
    outline: none;
    background: transparent;
    margin-left: 15px;
    height: 100%;
    flex: 2;
  }
  img {
    width: 0.533333rem;
    height: 0.533333rem;
    display: block;
    margin-right: 15px;
  }
}
.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 8.64rem;
  margin: 0 auto;
  height: 1.986667rem;
  border-bottom: 1px solid #e5e5e5;
  .infos {
    display: flex;
    align-items: center;
    text-align: left;
    img {
      width: 1.013333rem;
      height: 1.013333rem;
      display: block;
      border-radius: 50%;
      background: #000;
      margin-right: 0.186667rem;
    }
    p {
      color: #555;
      font-size: 0.4rem;
    }
    span {
      color: #999;
      font-size: 0.25rem;
    }
  }
  .icon {
    width: 15px;
  }
}
.item:nth-last-of-type() {
  border: none;
}
</style>
<style>
.van-index-bar__index {
  font-size: 12px;
  line-height: 20px;
}
</style>
<script>
import { Empty } from "vant";
import { getProxyCustomerList } from "@/utils/interface";
export default {
   components: {
    Empty
  },
  data() {
    return {
    
      list: [],
      username: "",
      defaultImg: 'this.src="' + require("../assets/user.png") + '"',
      refreshing: false,
      state: 0
    };
  },
  methods: {
    onRefresh() {
      this.getProxyCustomerListfs();
    },
    next(id) {
      this.$router.push({
        path: "showOrder",
        query: { user_id: JSON.stringify(id) }
      });
    },
    getProxyCustomerListfs(username) {
      getProxyCustomerList({ username: username }).then(res => {
        this.list = res.data.data;
        this.refreshing = false;
        if (this.list.length == 0) {
          this.state = 1;
        }
        console.log(this.list);
      });
    },
    search() {
      this.getProxyCustomerListfs(this.username);
    }
  },
  created() {
    document.title="代发订单"
    this.getProxyCustomerListfs();
    document.title = "发货订单";
  }
};
</script>